package com.itsq.controller.resources;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itsq.common.base.BaseController;
import com.itsq.common.bean.ErrorEnum;
import com.itsq.common.bean.Response;
import com.itsq.pojo.dto.PageCarDto;
import com.itsq.pojo.dto.PageChangeDto;
import com.itsq.pojo.entity.Car;
import com.itsq.pojo.entity.Change;
import com.itsq.service.resources.ChangeService;
import com.itsq.token.CurrentUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 史先帅
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/change")
@AllArgsConstructor
@CrossOrigin
@Api(tags = "汽车分配记录模块")
public class ChangeController  extends BaseController {

    @Autowired
    private ChangeService changeService;

    @PostMapping("selChangePageFront")
    @ApiOperation(value = "汽车分配记录模块前台分页查询", notes = "", httpMethod = "POST")
    public Response<Page<Change>> selChangePageFront(@RequestBody PageChangeDto pageChangeDto){
        Page<Change> ChangePage = changeService.selChangePageFront(pageChangeDto);
        return Response.success(ChangePage);
    }

    @PostMapping("selChangePageAfter")
    @ApiOperation(value = "管理员——汽车分配记录模块后台分页查询", notes = "", httpMethod = "POST")
    public Response<Page<Change>> selChangePageAfter(@RequestBody PageChangeDto pageChangeDto){
        CurrentUser currentUser = currentUser();
        if(currentUser==null){
            return Response.fail(ErrorEnum.SIGN_VERIFI_EXPIRE);
        }
        Page<Change> ChangePage = changeService.selChangePageAfter(pageChangeDto);
        return Response.success(ChangePage);
    }

}

